<template>
  <div>
    <p>前往主页中...</p>
  </div>
</template>

<script setup lang="ts" name="basicForm">
import { ElMessage, FormInstance, FormRules, ElNotification } from "element-plus";
import { ref, reactive, onMounted, onBeforeUnmount } from "vue";
import { useRoute, useRouter } from "vue-router";
import { useTabsStore } from "@/stores/modules/tabs";
import { useUserStore } from "@/stores/modules/user";
import { useKeepAliveStore } from "@/stores/modules/keepAlive";
import { initDynamicRouter } from "@/routers/modules/dynamicRouter";
const router = useRouter();
const route = useRoute();
const userStore = useUserStore();
const tabsStore = useTabsStore();
const keepAliveStore = useKeepAliveStore();

onMounted(() => {
  userStore.setMenuFlag("index");
  //编辑时加载数据
  let query = JSON.parse(JSON.stringify(route.query));
  console.log("sssssssssssss");
  // findByTemplateId findCiByIds
  if (query.isTanping != undefined) {
    console.log("sssssssssssss");

    if (query.eno != undefined) {
      // 2.添加动态路由
      initDynamicRouter().then(res => {
        // 3.清空 tabs、keepAlive 数据
        tabsStore.setTabs([]);
        keepAliveStore.setKeepAliveName([]);
        // 4.跳转到首页
        router.push("/eventManagement/index?eno=" + query.eno);
      });
    } else {
      // 2.添加动态路由
      initDynamicRouter().then(res => {
        // 3.清空 tabs、keepAlive 数据
        tabsStore.setTabs([]);
        keepAliveStore.setKeepAliveName([]);
        // 4.跳转到首页
        router.push("/eventManagement/index?type=add");
      });
    }
  } else {
    // 2.添加动态路由
    initDynamicRouter().then(res => {
      // 3.清空 tabs、keepAlive 数据
      tabsStore.setTabs([]);
      keepAliveStore.setKeepAliveName([]);
      // 4.跳转到首页
      router.push("/home/index");
    });
  }
  // if (query.eno != undefined) {
  // 	console.log("查看")
  // 	detailsMask.value.open({eno:query.eno});
  // 	//addEventMask.value.open({eno:query.eno});
  // }
});
</script>

<style scoped lang="scss">
@import "./index";
.item {
  width: 500px;
}
</style>
